package com.tomvian.twodee.common.actions 
{
	import com.tomvian.twodee.common.Actor;
	import com.tomvian.twodee.common.interactions.Interaction;
	import com.tomvian.twodee.common.StateDisplay;
	/**
	 * Dying
	 * @author Thomas Vian
	 */
	public class Dying extends Action
	{
		//--------------------------------------------------------------------------
		//
		//  Properties
		//
		//--------------------------------------------------------------------------
		
		protected var _displayState:String;
		
		protected var _causeOfDeath:Interaction;
		
		protected var _stillDeath:Boolean;
		
		//--------------------------------------------------------------------------
		//
		//  Getters / Setters
		//
		//--------------------------------------------------------------------------
		
		//--------------------------------------------------------------------------
		//
		//  Constructor
		//
		//--------------------------------------------------------------------------
		
		public function Dying(actor:Actor, displayState:String, causeOfDeath:Interaction, still:Boolean = true, stateDisplay:StateDisplay = null) 
		{
			super(actor);
			
			_displayState = displayState;
			
			_causeOfDeath = causeOfDeath;
			
			_stillDeath = still;
			
			if (stateDisplay) actorState = stateDisplay;
		}
		
		//--------------------------------------------------------------------------
		//
		//  Methods
		//
		//--------------------------------------------------------------------------
		
		override public function start():void 
		{
			_causeOfDeath.enabled = false;
			
			if (_stillDeath)
			{
				actorMass.velocity.x = 0;
				actorMass.velocity.y = 0;
			}
		}
		
		override public function stop():void 
		{
			_causeOfDeath.enabled = true;
		}
		
		override public function act():void 
		{
			if (_stillDeath)
			{
				actorMass.velocity.x = 0;
				actorMass.velocity.y = 0;
			}
		}
		
		override public function display():void 
		{
			actorState.state = _displayState;
		}
	}
}